// common_types.h
#pragma once
#include <string>

namespace MiniDB {
    // 定义 DataType 枚举
    enum class DataType {
        INT,
        VARCHAR,
        FLOAT,
        BOOLEAN,
        DATE,
        TEXT
    };

    struct ColumnInfo {
        std::string name;
        std::string type; // 保持为字符串类型
        int size;
        bool nullable;
        bool is_primary_key;
        
        // 默认构造函数
        ColumnInfo() : size(0), nullable(true), is_primary_key(false) {}
        
        // 字符串类型的构造函数
        ColumnInfo(const std::string& col_name, const std::string& col_type,
                  int col_size = 0, bool is_nullable = true, bool is_pk = false)
            : name(col_name), type(col_type), size(col_size), 
              nullable(is_nullable), is_primary_key(is_pk) {}
        
        // DataType 枚举类型的构造函数（可选）
        ColumnInfo(const std::string& col_name, DataType data_type,
                  int col_size = 0, bool is_nullable = true, bool is_pk = false)
            : name(col_name), size(col_size), nullable(is_nullable), is_primary_key(is_pk) 
        {
            switch (data_type) {
                case DataType::INT: type = "INT"; break;
                case DataType::VARCHAR: type = "VARCHAR"; break;
                case DataType::FLOAT: type = "FLOAT"; break;
                case DataType::BOOLEAN: type = "BOOLEAN"; break;
                case DataType::DATE: type = "DATE"; break;
                case DataType::TEXT: type = "TEXT"; break;
                default: type = "UNKNOWN"; break;
            }
        }
    };
}